package cn.wolfcode.wolf2w.business.listener;

import cn.wolfcode.wolf2w.business.domain.StrategyCannal;
import com.alibaba.fastjson.JSON;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Component;
import top.javatool.canal.client.annotation.CanalTable;
import top.javatool.canal.client.handler.EntryHandler;

import javax.annotation.Resource;

@Component
@CanalTable("ta_strategy")
public class StrategyListener implements EntryHandler<StrategyCannal> {
    @Resource
    private AmqpTemplate amqpTemplate;
    @Override
    public void insert(StrategyCannal strategyCannal) {
        System.out.println(strategyCannal);
        String jsonString = JSON.toJSONString(strategyCannal);
        //发送消息
        amqpTemplate.convertAndSend("strategyExchange","strategy.insert",jsonString);

    }


}
